<template>
  <van-tabbar-item>
    <van-icon slot="icon" name="star" color="#ffa500" v-if="is_collected" @click="isCollected" />
    <van-icon slot="icon" name="star-o" v-else @click="isCollected" />
  </van-tabbar-item>
</template>
<script>
import { collectedart_api, nocollectedart_api } from "@/api/user.js";
export default {
  props: ["is_collected", "artId"],
  methods: {
    // 是否收藏
    async isCollected() {
      //   this.is_collected = !this.is_collected;
      if (!this.is_collected) {
        const { data: res } = await collectedart_api(this.artId);
        this.$toast("收藏成功");
        console.log(res, this.is_collected, 123456);
      } else {
        const { data: res } = await nocollectedart_api(this.artId);
        console.log(res, this.is_collected, 11123456);
        this.$toast("取消收藏");
      }
      this.$emit("cc", !this.is_collected);
    },
  },
};
</script>
<style lang='less' scoped>
.van-tabbar-item:first-child {
  /deep/ .van-tabbar-item__text {
    width: 300px;
    height: 40px;
    margin-left: 30px;
    margin-right: 15px;
    border: 1px solid #ccc;
    border-radius: 20px;
    .van-button--round {
      width: 100%;
      height: 40px;
      line-height: 40px;
    }
  }
}
</style>